<!DOCTYPE html>
<html class="ui-page-login">
<head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
    <title></title>
    <script src="__PUBLIC__/js/jquery.min.js"></script>
    <script src="__PUBLIC__/home/plugins/layer/layer.js"></script>
    <script src="__PUBLIC__/mui/js/mui.min.js"></script>
    <script src="__PUBLIC__/js/angular.js"></script>
    <script src="__PUBLIC__/common.js"></script>
    <link rel="stylesheet" href="__PUBLIC__/mui/css/mui.css" />
    <link rel="stylesheet" href="__PUBLIC__/mui/css/mui.picker.css" />
    <link rel="stylesheet" href="__PUBLIC__/mui/css/mui.poppicker.css" />
    <script src="__PUBLIC__/mui/js/mui.picker.js"></script>
    <script src="__PUBLIC__/mui/js/mui.poppicker.js"></script>
    <style>

        #member-login{
            display: none;
        }
        .area {
            margin: 20px auto 0px auto;
        }

        .mui-input-group {
            margin-top: 10px;
        }

        .mui-input-group:first-child {
            margin-top: 5px;
        }

        .mui-input-group label {

            font-size: 15px;
            color: black;

        }

        .mui-input-row label~input,
        .mui-input-row label~select,
        .mui-input-row label~textarea {
            width: 85%;
            font-size: 15px;
            text-indent: 1em;
            color: #333333;
        }

        .mui-input::-webkit-input-placeholder
        {
          /*  text-align: right;*/
            padding-right: 2em;
            font-size: 12px;
            line-height: 40px;
        }

        .mui-checkbox input[type=checkbox],
        .mui-radio input[type=radio] {
            top: 6px;
        }

        .mui-content-padded {
            margin-top: 25px;
        }

        .mui-btn {
            padding: 10px;
        }

        .link-area {
            display: block;
            margin-top: 25px;
            text-align: center;
        }

        .spliter {
            color: #bbb;
            padding: 0px 8px;
        }

        .oauth-area {
            position: absolute;
            bottom: 20px;
            left: 0px;
            text-align: center;
            width: 100%;
            padding: 0px;
            margin: 0px;
        }

        .oauth-area .oauth-btn {
            display: inline-block;
            width: 50px;
            height: 50px;
            background-size: 30px 30px;
            background-position: center center;
            background-repeat: no-repeat;
            margin: 0px 20px;
            /*-webkit-filter: grayscale(100%); */
            border: solid 1px #ddd;
            border-radius: 25px;
        }

        .oauth-area .oauth-btn:active {
            border: solid 1px #aaa;
        }

        .oauth-area .oauth-btn.disabled {
            background-color: #ddd;
        }

        .login-active {
            background: #f3363a;
        }
        .mui-input-group .enter{
            background: url("__PUBLIC__/images/enter-right.png")no-repeat;!important ;
            background-position: right 1em center;
            background-size: auto 50%;
        }
        a{
            text-decoration: none;

        }
        .tip{
            height: 35px;background: #ffefd4;
            color: #f96230;
            line-height: 35px;
            padding-left: 1.5em;
            font-size: 16px;

        }
        .agentmsg .time{
            width: 50%;
            height: 80px;
        }
        .agentmsg{

            text-align: center;
            box-sizing: border-box;
            padding:0
        }

        .enter p{
            margin: 0;
            color: #333333;
        }

        .enter label{
            display: block;
            width: 20%;
            height: 100%;
            background: url("__PUBLIC__/images/cardicon.png");
            background-repeat: no-repeat;
            background-size: auto 60%;
            background-position: center;
        }

        #tixian:after{
            background-color: white;
        }
.money-bg{height: 28vw ;background: url("__PUBLIC__/images/gold.png")no-repeat;
background-size: auto 80%;background-position: center bottom}
.money-title{height: 8vw;font-size: 20px;color: #323232; text-align: center;margin-bottom: 0;}
.money-count{height: 24vw;font-size: 60px;
    line-height: 18vw;color: #323232;text-align: center }
    </style>
    <link rel="stylesheet" href="__PUBLIC__/js/nice-validator-0.10.11/dist/jquery.validator.css" />
    <script src="__PUBLIC__/js/nice-validator-0.10.11/dist/jquery.validator.js"></script>
    <script src="__PUBLIC__/js/nice-validator-0.10.11/dist/local/zh-CN.js"></script>
</head>
<body ng-app="myApp" ng-controller="Ctrl" ng-cloak>
<header class="mui-bar mui-bar-nav" style="background:#f3363a;" >
    <a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left" style="color: white"></a>
    <h1 class="mui-title login-item" style="color: white">提现</h1>
</header>

<div class="mui-content" id="user-login" >
    <div class="mui-input-group" style="margin-top: 0">
        <!--  <div class="mui-row tip">
              提示:最低拿货金额1000元
          </div>-->
        <div class="mui-input-row agentmsg" style="background:white;height: 60vw">
            <p class="money-bg"></p>
            <p class="money-title">我的金币</p>
            <p class="money-count">{{recharge.balance}}</p>

        </div>
    </div>
    <form class="mui-input-group" method="post" action="" style="margin-top: 0;  background: #efeff4;" data-validator-option="{stopOnError:false, timely:true,theme:'layer'}">

        <div class="mui-input-group">
            <a href="javascript:void (0)" id="showUserPicker" >
                <div class="mui-input-row enter" style="height: 60px">
                    <label></label>
                       <p style="margin-top: 9px" ng-model="user_bank.name" id="bankname">{{user_bank.bankname}}</p>
                        <p ng-model="user_bank.number" id="banknumber">{{user_bank.number}}</p>
                    <input type="hidden" id="bankid" ng-model="user_bank.id" ng-value="user_bank.id">
                </div> </a>
        </div>
        <div class="mui-input-group" style="margin-top: 5px">
            <div class="mui-input-row " id="tixian">
                <label style="width: 100%;color: #4d4d4d">提现金额</label>
            </div>
            <div class="mui-input-row">
                <label style="padding: 0;font-size: 24px;line-height: 40px;font-weight: bold;width: 15%;text-align: right">￥</label>
                <input style="padding: 0;font-size: 24px;margin-left: 0"
                       type="text" class="mui-input-clear mui-input" placeholder="可转出到卡{{recharge.balance}}元" ng-model="count" value="count" />
            </div>
            <div class="mui-input-row">
                <label style="width: 100%" style="color: #999999">当前可提现余额{{recharge.balance}}元,<span style="color: #f2373b" ng-click="all()">全部提现</span></label>
            </div>
        </div>
        <div class="mui-input-row">
            <label style="width: 25%">验证码</label>
            <input name='mobilecode' type="text" class="mui-input-clear mui-input" placeholder="请输入验证码" style="width: 45%;float: left" ng-model="mobilecode" >
            <button name='acquire' id="getcode" class="mui-input-clear mui-input" value="" style="width: 28%;float: left;height: 30px;margin-top:5px;margin-right: 2%" onclick="getnum()">验证码</button>
        </div>
    </form>
    <p class="mui-pull-right" style="padding-right: 1em">提示:1金币等于1元人民币</p>
    <div class="mui-content-padded">
        <button id="login" class="mui-btn mui-btn-block mui-btn-danger" style="line-height: 1" ng-click="submit()">确认提现</button>
    </div>
    <div class="mui-content-padded oauth-area">
    </div>
</div>

<include file="./Application/Home/View/pub/agentfoot.html" />
<script>
    function getnum() {
        var time = 60;
        var t;

        $("#getcode").attr("disabled", true);
        $.post("{:U('Account/getnum')}", {account: $("#username").val()}, function (data) {
            if (data.code == 0) {
                $("#getcode").html(time + "s");
                t = setInterval(countdown, 1000);
            } else {
                layer.msg(data.msg,{time:1000})
//     layer.alert(data);
            }
        });

        function countdown() {
            time = time - 1;
            $("#getcode").html(time + "s");
            $("#getcode").attr("disabled", true);
            if (time == 0) {
                $("#getcode").html("验证码");
                clearInterval(t);
                $("#getcode").attr("disabled", false);
            }
        }
    }

    var app = getApp('myApp', []);
    app.controller('Ctrl', function ($scope, $http) {
            $http({
                method: 'POST',
                headers: {'Content-Type': 'application/x-www-form-urlencoded'},
                transformRequest: function (obj) {
                    var str = [];
                    for (var p in obj) {
                        str.push(encodeURIComponent(p) + "=" + encodeURIComponent(obj[p]));
                    }
                    return str.join("&");
                },
                url: "/index.php/Home/Account/cash"
            }).then(function successCallback(response) {
             if (response.data.code==-1){
                 layer.msg(response.data.msg,{time:1000})
                 setTimeout(function () {
                    window.location.href=" /index.php/Home/agen/cardlist";
                 },1500)
             }else {
                 $scope.recharge= response.data.data.recharge;
                 $scope.user_bank= response.data.data.user_bank;

                 console.log(response.data.data.user_all_bank)
                 var data=[];
                 for (var x in response.data.data.user_all_bank){
                     data[x]={};
                     data[x]['value']=response.data.data.user_all_bank[x].id;
                     data[x]['text']=response.data.data.user_all_bank[x].bankname+":"+response.data.data.user_all_bank[x].number;
                     data[x]['name']=response.data.data.user_all_bank[x].bankname;
                 }
                 var userPicker = new mui.PopPicker();
                 userPicker.setData(data);
                 var showUserPickerButton = document.getElementById('showUserPicker');
                 var userResult = document.getElementById('userResult');
                 showUserPickerButton.addEventListener('tap', function(event) {
                     userPicker.show(function(items) {
                         document.getElementById('banknumber').innerText=items[0]['text'].split(":")[1];
                         document.getElementById('bankid').value=items[0]['value'];
                         document.getElementById('bankname').innerText=items[0]['name']
                         /*  expid.value = JSON.stringify(items[0]['value']);*/
                     });
                 }, false);
                 if (response.data.code == -1) {
                     layer.msg(response.data.msg, {time: 1000})
                 }


             }
            }, function errorCallback(response) {
                errorHandle(response);
            });
          $scope.all=function () {
                  $scope.count=$scope.recharge.balance
          }

        $scope.submit = function () {
            var data = {amount:$scope.count, bankinfo:$("#bankid").val(),mobilecode:$scope.mobilecode};
            console.log(data)
            $http({
                method: 'POST',
                data: data,
                headers: {'Content-Type': 'application/x-www-form-urlencoded'},
                transformRequest: function (obj) {
                    var str = [];
                    for (var p in obj) {
                        str.push(encodeURIComponent(p) + "=" + encodeURIComponent(obj[p]));
                    }
                    return str.join("&");
                },
                url: "/index.php/Home/Account/withdrawal"
            }).then(function successCallback(response) {
                console.log(response)
                if (response.data.code == -1){
                    layer.msg(response.data.msg, {time: 1000})
                }
                else if (response.data.code == 0) {
                    layer.msg(response.data.msg, {time: 1000});
                    setTimeout(function () {
                          window.location.href=window.location.href
                    }, 1500)
                }
            }, function errorCallback(response) {
                errorHandle(response);
            });

        }


    });
</script>
</body>
</html>